Regular expressions
Matches
| RE | Meaning |
|---|---|
| . | any char |
| * | any number of previous (including zero) |
| + | any number of previous |
| $ | end of line |
| ^ | beginning of the line |
| \S | any non-whitespace char |
| \s | any whitespace |
| ? | optional char |
| \ | escape char |
| [a-z] | any lowercase char |
| [A-Z] | any uppercase char |
| [A-Za-z] | any char at all |
| [0-9] | any number |
| [0-9][0-9] | any number 2 digits |
| [A-Za-z][0-5] | any char and any from 0 to 5 |
| * | Any line with an asterisk |
| \* | Any line with an asterisk |
| \ | Any line with a backslash |
| ˆ* | Any line starting with an asterisk |
| ˆA* | Any line |
| ˆA* | Any line starting with an “A*” |
| ˆAA* | Any line if it starts with one “A” |
| ˆAA*B | Any line with one or more “A”'s followed by a “B” |
| ˆA{4,8}B | Any line starting with 4, 5, 6, 7 or 8 “A”'s followed by a “B” |
| ˆA{4,}B | Any line starting with 4 or more “A”'s followed by a “B” |
| {4,8} | # Any line with “{4,8}” |
| A{4,8} | # Any line with “A{4,8}” |
More matches.
| RE | Class | Type | Meaning |
|---|---|---|---|
| . | all | Character Set | Single character (except newline) |
| ˆ | all | Anchor | Beginning of line |
| $ | all | Anchor | End of line |
| […] | all | Character Set | Range of characters |
| *a\< | Basic | Anchor | Beginning of word |
| > | Basic | Anchor | End of word |
| Basic | Backreference | Remembers pattern | |
| \1..\9 | Basic | Reference | Recalls pattern |
| _+ | Extended | Modifier | One or more duplicates |
| ? | Extended | Modifier | Zero or one duplicate |
| {MN} | Extended | Modifier | M to N Duplicates |
| (…\ …) | Extended | Anchor | Shows alteration |
| alteration | EMACS | Anchor shows alteration | |
| \w | EMACS | Character set | Matches a letter in a word |
| \W | EMACS | Character set | Opposite of \wll Modifier zero or more duplicates* |
E-mail RE
About
Author
- Name: Frederico Sales
- link: https://assintotica.xyz
- e-mail: frederico@fredericosales.eng.br
- slug: regular-expressions
- date: 2024-11-19